package myaop.dao;

import com.sun.deploy.util.ArrayUtil;
import myaop.pojo.User;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository("userDao")
public class UserDaoImpl implements UserDao{
    @Override
    public int save(User user) {
        System.out.println("UserDaoImpl>>save(User)");
        return 0;
    }

    @Override
    public int update(User user) {
        System.out.println("UserDaoImpl>>update(User)");
        return 0;
    }

    @Override
    public int saveById(int id, String name) {
        System.out.println("UserDaoImpl>>saveById(id,name)");
        return 99;
    }

    @Override
    public List findById(int id) {
        List<String> list = new ArrayList<String>(){
            {add("曹良玉");}
            {add("曹阿玉");}
            {add("曹小玉");}
        };

        if (id==1){
            throw new NullPointerException("抛一个空指针异常试试");
        }

        return list;
    }

    @Override
    public List<String> findByName(String name) {
        System.out.println("UserDaoImpl>>findByName(name)");
        return new ArrayList<String>(){
            {add("曹良玉A");}
            {add("曹阿玉A");}
            {add("曹小玉A");}
        };
    }
}
